<template>
  <van-swipe :autoplay="3000" lazy-render>
    <van-swipe-item v-for="image in images" :key="image.encodeId">
      <img :src="image.pic" />
    </van-swipe-item>
  </van-swipe>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { getBanner } from '@/request/api/home'
const images = ref([])
onMounted(async () => {
  // 拿到的是promise成功的值
  const res = await getBanner()
  images.value = res.data.banners
})
</script>
<style lang='scss' scoped>
.van-swipe {
  width: 100%;
  .van-swipe__track {
    .van-swipe-item {
      img {
        width: 100%;
        height: 4rem;
      }
    }
  }
}
</style>
